package cn.doitedu.profile.preprocess
import scala.collection.immutable

/**
  * @author: 余辉  
  * @blog: https://blog.csdn.net/silentwolfyh
  * @create: 2019-11-12 08:00
  * @description:
  **/
class implicitTest(s: String) {

  def toplusInt: Int = {
    var num = 0
    try {
      num = s.toInt
    } catch {
      case e: Exception => null
    }
    num
  }
}

object implicitTest {
  def main(args: Array[String]): Unit = {

    //隐士转换 implicit ,调用函数的时候，new一个类，在new的类中找方法
    implicit def toMyInt(s: String): implicitTest = new implicitTest(s)

    List("11", "22").map(row => (row.toplusInt + 11)).foreach(println)
    List("11", "22").map(row => (row.toplusInt + 11)).foreach(println)

//    val arr = Array("null","null","1")
//    val ids: immutable.IndexedSeq[String] = for (i <- 0 until arr.length) yield arr(i)
//    val idsStr: String = ids.mkString("").replaceAll("null", "").trim
//    val flag2: Boolean = !idsStr.equals("")
//    println(flag2)
  }
}